package com.zq.learn.springbatch.combination.batch;

import com.zq.learn.springbatch.mongo.StatisticsResult;
import com.zq.learn.springbatch.mongo.sourcedata.SourceData;
import org.springframework.batch.item.ItemProcessor;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * OrderPriceProcessor
 *
 * @author ZhangQi
 * @date 2020/2/19
 */
public class OrderPriceProcessor implements ItemProcessor<SourceData, StatisticsResult> {
  //金额累积
  private int price;

  @Override public StatisticsResult process(SourceData sourceData) throws Exception {
    price+=sourceData.getPrice();
    String day = sourceData.getTimestamp().substring(0, 8);
    return new StatisticsResult("price_"+day,day,"price",price);
  }
}
